package com.edu.method;

public class ThreadMethod01 {

    public static void main(String[] args) throws InterruptedException {

        T t = new T();
        t.start();

        Thread.sleep(5000);
        t.interrupt();
    }
}

class T extends Thread{
    @Override
    public void run() {

        while (true){
            for (int i = 0; i <5 ; i++) {
                System.out.println("吃包子" + i );
            }
            try {
                System.out.println(Thread.currentThread().getName()+"休眠中~");
                Thread.sleep(20000);
            } catch (InterruptedException e) {
                e.printStackTrace();
                System.out.println(Thread.currentThread().getName()+"被中断了");
            }
        }
    }
}

